//
// Created by YimingCai on 25/03/2017.
//

#include <vector>

using namespace std;

class Solution {
public:
    vector<int> twoSum(vector<int>& nums, int target) {
        vector<int> ret;
        for (auto i = 0; i < nums.size() - 1; ++i) {
            for (auto j = i + 1; j < nums.size(); ++j) {
                if (nums[i] + nums[j] == target) {
                    ret.push_back(i);
                    ret.push_back(j);
                }
            }
        }
        return ret;
    }
};



#include <gtest/gtest.h>

TEST(TwoSumTest, test1)
{
    vector<int> nums1 = {2, 7, 11, 15};
    vector<int> ret1 = Solution().twoSum(nums1, 9);
    EXPECT_EQ(2, ret1.size());
    EXPECT_EQ(0, ret1[0]);
    EXPECT_EQ(1, ret1[1]);
}

TEST(TwoSumTest, test2)
{
    vector<int> nums1 = {1, 7, 6, 15};
    vector<int> ret1 = Solution().twoSum(nums1, 16);
    EXPECT_EQ(2, ret1.size());
    EXPECT_EQ(0, ret1[0]);
    EXPECT_EQ(3, ret1[1]);
}

int main(int argc, char** argv)
{
    ::testing::InitGoogleTest(&argc, argv);
    int ret = RUN_ALL_TESTS();
    return ret;
}
